<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: pl125 <xskjs888@163.com>
// +----------------------------------------------------------------------

namespace api\wxapp\controller;

use api\wxapp\controller\ApiBaseController;
use think\Db;
use api\wxapp\model\Order;
use api\wxapp\model\Refund;
class RefundController extends ApiBaseController
{

    public function index()
    {
        $params = $this->getParam();
        //查询当前订单状态
        !isset($params['order_id']) ? $this->error('参数缺失!!!!') : '';
        !isset($params['apply_price']) ? $this->error('参数缺失!!!!') : '';
        !isset($params['goods_price']) ? $this->error('参数缺失!!!!') : '';
        !isset($params['type']) ? $params['type'] = 1 : '';
        !isset($params['reason']) ? $this->error('参数缺失!!!!') : '';
        $find = Order::get($params['order_id']);
        $params['is_coupon'] = $find['is_coupon'];
        $params['is_score'] = $find['score'];
        $params['addtime'] = $this->returnDateTime();
        $res = Refund::insert($params);
        if($res){
            $this->success('申请成功!',true);
        }else{
            $this->error('申请失败!',false);
        }
    }
}
